package com.haisen.config;

import com.haisen.core.aspect.DataChangeLastTimeInterceptor;
import org.apache.ibatis.session.SqlSessionFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import tk.mybatis.spring.annotation.MapperScan;



@Configuration
@MapperScan(basePackages = "com.haisen.dataobject.mapper.**")
public class MyBatisConfig {

    /**
     * 通过哦拦截器，监测更新操作，updateTime进行更新，
     * @param sqlSessionFactory
     * @return
     */
    @Bean
    public String UpdateTimeInterceptor(SqlSessionFactory sqlSessionFactory) {
        DataChangeLastTimeInterceptor dataChangeLastTimeInterceptor = new DataChangeLastTimeInterceptor();
        sqlSessionFactory.getConfiguration().addInterceptor(dataChangeLastTimeInterceptor);
        return "interceptor";
    }


}
